package utils;

import java.net.URLDecoder;
import java.net.URLEncoder;

public class MyUrl {

    public String encode(String str) throws Exception {
        String url = URLEncoder.encode(str,"utf-8");
        System.out.println(url);
        return url;
    }

    public String decoder(String str) throws Exception {
        String url = URLDecoder.decode(str,"utf-8");
        System.out.println(url);
        return url;
    }

    public static void main(String[] args) throws Exception {

        String url = "http://www.baidu.com?a=b&c=d+a";

        MyUrl myUrl = new MyUrl();

        url = myUrl.encode(url);
        //url = myUrl.encode(url);

        //url = myUrl.decoder(url);
        myUrl.decoder(url);
    }

}
